
/*
 * LPC214x_SPI0.h - Philips LPC214x Device Library
 *                  SPI Interface (SPI0)
 *
 * Copyright 2008 Luit van Drongelen
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * This file was set up using the "LPC214x User Manual (Rev. 02 — 25 July 2006)"
 * The User Manual is available at the website of NXP (ex-Philips chip devision)
 *   http://www.standardics.nxp.com/products/lpc2000/lpc214x/
 *
 */

#ifndef __LPC2148_SPI0_H__
#define __LPC2148_SPI0_H__

/* SPI Control Register (S0SPCR - 0xE002 0000) */
typedef union 
{
	unsigned int word;
	unsigned short halfword[2];
	unsigned char byte[4];
	struct 
	{
		unsigned :2;
		unsigned BitEnable:1;
		unsigned CPHA:1;
		unsigned CPOL:1; 
		unsigned MSTR:1;
		unsigned LSBF:1;
		unsigned SPIE:1;
		unsigned BITS:4;
	};
} S0SPCR_t;

/* SPI Status Register (S0SPSR - 0xE002 0004) */
typedef union 
{
	unsigned int word;
	unsigned short halfword[2];
	unsigned char byte[4];
	struct
	{
		unsigned :3;
		unsigned ABRT:1;
		unsigned MODF:1;
		unsigned ROVR:1;
		unsigned WCOL:1;
		unsigned SPIF:1;
	};
} S0SPSR_t;

/* SPI Data Register (S0SPDR - 0xE002 0008) */
typedef union 
{
	unsigned int word;
	unsigned short halfword[2];
	unsigned char byte[4];
	struct 
	{
		unsigned DataLow:8;
		unsigned DataHigh:8;
	};
} S0SPDR_t;

/* SPI Clock Counter Register (S0SPCCR - 0xE002 000C) */
typedef union
{
	unsigned int word;
	unsigned short halfword[2];
	unsigned char byte[4];
	struct 
	{
		unsigned Counter:8;
	};
} S0SPCCR_t;

/* SPI Interrupt Register (S0SPINT - 0xE002 001C) */
typedef union
{
	unsigned int word;
	unsigned short halfword[2];
	unsigned char byte[4];
	struct
	{
		unsigned Flag:1;
	};
} S0SPINT_t;

volatile S0SPCR_t*  S0SPCR  = (volatile S0SPCR_t*)  0xe0020000;
volatile S0SPSR_t*  S0SPSR  = (volatile S0SPSR_t*)  0xe0020004;
volatile S0SPDR_t*  S0SPDR  = (volatile S0SPDR_t*)  0xe0020008;
volatile S0SPCCR_t* S0SPCCR = (volatile S0SPCCR_t*) 0xe002000c;
volatile S0SPINT_t* S0SPINT = (volatile S0SPINT_t*) 0xe002001c;

#endif

